<!--企业信息-->
<template>
    <div class="page_companyInfo">
        <common-header :title="'企业信息'" :showBack="false"></common-header>
        <div class="pages-main" style="height: calc( 100vh - 93px)">
            <div class="item-info">
                <div class="item-item every-block-padding item-inline">
                    <span class="item-itemLabel">企业类型</span>
                    <select class="translateBlock" v-model="category"
                            style="text-align-last: right;;width: 7rem;font-size:0.38rem;">
                        <option v-for="item in list" :value="item.id">{{item.title}}</option>
                    </select>
                </div>
            </div>
            <section class="search-block every-block-padding">
                <input class="common-input input-search" v-model="keywords"  @focus="hideClass = true" @blur="onBlurInput" placeholder="请输入企业名字"/>
                <div class="translateBlock" style="width: 1.2rem;text-align: center;" @click="getCompanyList">搜索</div>
            </section>
            <section class="search-result every-block-bgcolor every-block-padding " v-for="(item,index) in results">
                <div>{{item.name}}</div>
                <div>主营：{{item.maincamp}}</div>
                <div>
                    <div class="translateBlock" style="width: 1.2rem;vertical-align: top;">
                        地址：
                    </div>
                    <div class="translateBlock" style="line-height: 0.5rem;width: 7.5rem;">{{item.location}}</div>
                </div>
                <div>
                    <div class="translateBlock" style="margin-right: 0.3rem;">法人：{{item.contactuser}}</div>
                    <div class="translateBlock">电话：{{item.contactphone}}</div>
                </div>
                <div style="text-align: right;">
                    <div class="translateBlock" style="margin-right: 0.15rem;"
                         @click="$tools.goPage_query('companyDetail',{id:item.id})">
                        <img src="../../../static/images/bj_03.png" alt="" width="16"/>
                        编辑
                    </div>
                    <div class="translateBlock" @click="deleteCompany(item.id)">
                        <img src="../../../static/images/del_03.png" alt="" width="16"/>
                        删除
                    </div>
                </div>
            </section>
            <div class="no-more-data">
                --暂无更多数据--
            </div>
            <div v-transfer-dom>
                <confirm v-model="isShowDeleteDialog"
                         :title="'确认删除框'"
                         @on-cancel="onCancel"
                         @on-confirm="onConfirm">
                    <p style="text-align:center;">您确定要删除该数据吗？</p>
                </confirm>
            </div>
        </div>
        <common-footer v-show="!hideClass"></common-footer>
    </div>
</template>

<script>
    import {XInput, Selector} from 'vux'
    import company from '../../services/company'

    export default {
        name: 'companyInfo',
        components: {
            XInput,
            Selector
        },
        data() {
            return {
                hideClass: false,
                docmHeight: document.documentElement.clientHeight,  //一开始的屏幕高度
                showHeight: document.documentElement.clientHeight,   //一开始的屏幕高度
                isShowDeleteDialog: false,
                companyId: '',
                category: '',  // 分类
                list: [],     // 类型列表
                keywords: '',    // 搜索关键字
                pagenum: 1,
                pagesize: 10,
                results: [],
            }
        },
        mounted() {
            this.getCompanyType();
            this.getCompanyList();
        },
        methods: {

            // 获取企业类型
            getCompanyType() {
                let _param = this.$tools.invokeUAF('enterprise/getCategoryOneList', {})
                company.getCategoryOneList(_param).then(res => {
                    let data = res.data.data;
                    this.list = data;
                    this.list.unshift({title: '全部', id: ''})
                })
            },

            //  获取企业列表
            getCompanyList() {
                let _param = this.$tools.invokeUAF('enterprise/list', {
                    category: this.category,
                    keywords: this.keywords,
                    pagenum: this.pagenum,
                    pagesize: this.pagesize,
                })
                company.getEnterpriseList(_param).then(res => {
                    let data = res.data.data;
                    this.results = data.list;
                })
            },

            // 删除
            deleteCompany(companyId) {
                this.isShowDeleteDialog = true;
                this.companyId = companyId;
            },

            // 确定删除
            onConfirm() {
                let _param = this.$tools.invokeUAF('enterprise/del', {
                    id: this.companyId,
                })
                company.delEnterprise(_param).then(res => {
                    this.getCompanyList()
                })
            },
            onCancel() {
                this.isShowDeleteDialog = false;
            },

            onBlurInput(){
                this.hideClass = false;
                window.scroll(0, 0)
            },
        },
    }
</script>

<style lang="less">
    .page_companyInfo {
    .search-block {
        overflow-y: auto;
        margin-top: 10px;
        padding-top: 0.3rem;
        padding-bottom: 0.15rem;
    .input-search {
        width: 7rem;
        margin-right: .1rem;
    }
    }
    .search-result {
        margin-top: 10px;
        line-height: 1rem;
    img {
        vertical-align: middle;
    }
    }
    .no-more-data {
        line-height: 2.5rem;
        text-align: center;
        font-size: .18em;
    }
    }
</style>
